import settings from "@/settings";
import { SET_TITLE, SET_LOGO } from "@/types/mutation-types";
const { title, logo } = settings;
const state = {
  title,
  logo,
};
const mutations = {
  [SET_TITLE]: function(state, payload) {
    state.title = payload.title;
  },
  [SET_LOGO]: function(state, payload) {
    const { logo } = payload;
    //使用结构赋值简化代码
    state.logo = logo;
  },
};
const actions = {
  [SET_TITLE]: function({ commit }, payload) {
    commit(SET_TITLE, {
      //以载荷形式提交
      title: payload.title,
    });
  },
  [SET_LOGO]: function({ commit }, payload) {
    //使用结构赋值简化代码
    commit({ type: SET_LOGO, logo: payload.logo });
  },
};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
};